// *********************************************************
// Intro.h - has most of the global variables needed in the game. 
// Sets up and initializes programming constants, and other very important variables. 
// *********************************************************


float cax,cay; //camera angles

// DEVELOPMENT VARIABLES
float test2=0;
float temp=0;

// voiceSound
boolean voiceSound =1;

//bullet life, 1= pos x, 2= pos z, 3= angle y
float BL[10][4]; //bullet life

float aiSt[20]; //speed limit???

float aiRSt[20];//rotation speed limit???

//explosion
float EX[10][2]; 

//PROGRAMMING CONSTANTS
const int M=0; //mode - battle mode
const int L=1; //life
const int X=2; //x position
const int Z=3; //z position
const int SS=4; //speed - two S's to distinguish from float S

const int RS=5; //rotation speed of vehicle

const int AY=7; //y angle

const int NX=8; //new xval?
const int NZ=9; //new xval?
const int NX2=10;
const int NZ2=11;

const int DX=12; //destination x
const int DZ=13; //destination z

const int ET=14; //enemy target - number of enemy
const int FW=15; //to fire weapon
const int PR=16; //bullet power
const int EN=17; //enemy #?
const int NX3=18;
const int NZ3=19;
const int AC=20; //acceleration
const int WR=21; //weapon recoil- how much time till anther fire
 
const int LS=22; //listening to commander between unit and commander
const int TM=23;

const int OWN=24; //who's the owner of such---for bullet
const int HIT=25; //counts up till next time unit can say "i'm hit"
const int DAM=26; //counts up till next time unit can say "i'm badly damgaged"
const int MOVM=27; //move mode for hurrying up

//RL=28 taken
const int CM=29; //command to unit
const int WR2=30; //weapon recoil for machine gun- how much time till anther fire
const int AR=31; //attack range- adjusted to keep units in range
const int PER=32; //person speaking
const int ML=33; //max life- calculate color
const int MOVEABLE=34; // distingish between buildings and vehicles (TEMP CODE TRICK to reduce programming work)

//AI states
const int noTurn=0;
const int explore=1;
const int setDest=2;
const int turnDet=3;
const int speedTo=4;

// vehicle states???
const int alert=1;
const int runAway=2;
const int fire=3;
const int damage=2;
const int death=1;

//for LS for units (listening status)
const int idle=0;
const int listening=1;

//for CM- needs WORK
const int attack= 1;
const int stop= 2; //same as idle
const int ffire= 3;
const int nfire= 4;
const int hfire= 5;

const int follow= 6;
const int retreat= 7;
const int move= 8;

//team
const int gold=0;
const int red=1;

//for INTERFACE
int enemiesLeft=0;
int alliesLeft=0;

//for debugging
int player=gold;

//bullets
const int BUL_LIFE=0;
const int BULX=1;
const int BULZ=2;
const int BULA=3;
const int BUL_OWNER=4;
//--------------------------


//click waiters for checking if mouse clicked or pressed. 
int clickWaiter[20][3]; // [x]  [0- limit, 1- time to wait, 2- if done or not]

//amount variables
int am=10; //amount 
int Wam=10;
int Eam=10; //enemy amount?



//mode that determines which music is played at what moment
int musicMode=0;

//music constants
int m_combat=9;
int m_death=6;
int m_title=7;
int m_idle=8;

//determines if game started, game in progress, or game ended, or in menu
int gameMode=0;

//determines how many units are selected or not, so that the commands can be applied to all
//	works in junction with drag select
int multiSelect=0;
int multiSelCount=0;

//mouse click- for dragging
int mouseClick=0; //0 = nothing, 1= clicked, 2= dragged
int mouseCounter=0; //counter

//for multi select code. 
const int clicked=1;
const int dragged=2;


//"catch" variables that find in a loop whether all vehicles are destroyed. 
int goldDeath=0;
int redDeath=0;

//OBJECT RANGES_____________
// tour plane object ids. 
const int tourPlaneStart=300; 
const int tourPlaneEnd=35; 

// bullet object ids.
const int bullNumStart=50; //bullet number
const int bullNumEnd=99; 

// vehicle object ids.
const int vehicleNumStart=100;
const int vehicleNumEnd=200; 
//---------------------------


//new building updated
//Makes a building. Input paramaters: building's id, the id of its roof, size of building,
//it's x position, its z position, building's texture, roof's texture


//id, Uval- how much to accelerate, sppedL- limit
void acce(int id,float Uval,float speedL) {
	if (abs((O[id][SS])<speedL)) 
		O[id][SS] += Uval;
}

//distance between objects
int withinRange(int id1, int id2, int distance) {
	return (dbSqrt( pow((O[id1][X] - O[id2][X]),2)
		+ pow((O[id1][Z] - O[id2][Z]),2) ) < distance);
}


// click detectors
int offOn(int x, int limit) { 

	// clickwaited [x]  [1- limit-XXX, 0- waited counter , XXX 2-if done or not]

	if (clickWaiter[x][0]==0) {
		clickWaiter[x][0]=1;
		return 1; //clicked
	}

	if (clickWaiter[x][0] >0) clickWaiter[x][0]++;

	if (clickWaiter[x][0] > limit) { 
		clickWaiter[x][0]=0;
	}
	return 0;//not done, nothing
}








